using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SQLDAL;
using System.Data.SqlClient;

public partial class GUI_Webpage_RestaurantDetails : System.Web.UI.Page
{
    #region Fields
    RestaurantBll resBll = new RestaurantBll();
    RestaurantInfo resInfo = new RestaurantInfo();
    SqlDataReader reader = null;
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        LoadRestaurantToDataView();
        if(!IsPostBack)
        resBll.LoadRestaurant(drpRestaurant);
    }

    protected void ddlRestaurant_SelectedIndexChanged(object sender, EventArgs e)
    {
        resInfo.ResID = drpRestaurant.SelectedValue.ToString();
        reader = resBll.ListDetailsRestaurant(resInfo);
        dtViewDetailsRestaurant.DataSource = reader;
        dtViewDetailsRestaurant.DataBind();
    }

    #region Load data to dataview when select a restaurant from Restaurantss
    public void LoadRestaurantToDataView()
    {
        // get the resID selected
        string resID = Request.QueryString.Get("resID");
        if (resID != "" && resID != null)
        {
            resInfo.ResID = resID;
            SqlDataReader reader = resBll.ListDetailsRestaurant(resInfo);
            dtViewDetailsRestaurant.DataSource = reader;
            dtViewDetailsRestaurant.DataBind();
        }
        else
            //link to Restaurant.aspx page
            Response.Redirect("Restaurants.aspx");
    }

    #endregion
}
